{% extends 'admin/base_site.html' %}
{% load i18n admin_urls static admin_list %}

{% if not is_popup %}
  {% block breadcrumbs %}
    <div class="breadcrumbs">
      <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
      &rsaquo; Management pages
      &rsaquo; Site Status
    </div>
  {% endblock %}
{% endif %}

{% block content %}
  <div id="content-main">
    <div>
      <h2>Service version info</h2>
      <table>
        <thead>
          <tr>
            <th>host</th>
            <th>version info</th>
          </tr>
        </thead>
        <tbody>
          {% for url, info in version_info.items %}
            <tr class="row1">
              <td>{{ url }}</td>
              <td>{{ info }}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>

    <div>
      <h2>Django db status</h2>
      {% if django_error %}
        <p>{{ django_error }}</p>
      {% else %}
        <table>
          <thead>
            <tr>
              <th>id</th>
              <th>app</th>
              <th>name</th>
              <th>applied</th>
            </tr>
          </thead>
          <tbody>
            {% for row in django_db_data %}
              <tr>
                <td>{{ row.id }}</td>
                <td>{{ row.app }}</td>
                <td>{{ row.name }}</td>
                <td>{{ row.applied }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      {% endif %}
    </div>

    <div>
      <h2>Crontabber failed jobs</h2>
      {% if crontabber_error %}
        <p>{{ crontabber_error }}</p>
      {% else %}
        <table>
          <thead>
            <tr>
              <th>app_name</th>
              <th>next_run</th>
              <th>last_run</th>
              <th>last_success</th>
              <th>error_count</th>
              <th>last_error</th>
            </tr>
          </thead>
          <tbody>
            {% for row in crontabber_data %}
              <tr>
                <td>{{ row.app_name }}</td>
                <td>{{ row.next_run }}</td>
                <td>{{ row.last_run }}</td>
                <td>{{ row.last_success }}</td>
                <td>{{ row.error_count }}</td>
                <td>{{ row.last_error }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      {% endif %}
    </div>
  </div>
{% endblock %}
